// 分页函数
// 参数 当前页码，每页记录数，总记录数，页面跳转方法，分页ID
var comPagination = function (currentPageNum, perPageSize, recordCount, paginationFunction, pageBarId) {


    if (recordCount) {

        var pageCount = Math.ceil(recordCount / perPageSize);
        //var maxPageLimit = function (number) {
        //    if (number > pageCount) {
        //        return pageCount;
        //    } else {
        //        return number;
        //    }
        //}
        isNaN(currentPageNum) ? "" : currentPageNum = parseInt(currentPageNum);
        currentPageNum > pageCount ? currentPageNum = pageCount : "";

        var sHtml = "<div id='" + pageBarId + "' class='pagination'><ul currentPageNum='" + currentPageNum + "'>";
        currentPageNum == 1 ? sHtml += "<li class='disabled'><a href='javascript:" + paginationFunction + "(1)'>第一页</a></li>" :
            sHtml += "<li><a href='javascript:" + paginationFunction + "(1)'>第一页</a></li>";

        if (currentPageNum > 1) {
            var prevPage = currentPageNum - 1;
            sHtml += "<li><a href='javascript:" + paginationFunction + "(" + prevPage + ")" + "'>上一页</a></li>"
        } else {
            sHtml += "<li class='disabled'><a href='javascript:(0)'>上一页</a></li>";
        }


        sHtml += "<input class='pageInput' maxPage='" + pageCount + "'" +
        "value='" + currentPageNum + "' type='text' " +
        "onkeydown='if(event.keyCode==13){changePageInput($(this), " + paginationFunction + ");}'>"

        sHtml += "<li class='totalpages' style='display: inline'>of " + pageCount + "</li>";

        if (currentPageNum < pageCount) {
            var nextPage = currentPageNum + 1;
            sHtml += "<li><a href='javascript:" + paginationFunction + "(" + nextPage + ")" + "'>下一页</a></li>";
        } else {
            sHtml += "<li class='disabled'><a href='javascript:(0)'>下一页</a></li>";
        }


        currentPageNum == pageCount ? sHtml += "<li class='disabled'><a href='javascript:" + paginationFunction + "(" + pageCount + ")'>最后一页</a></li>" :
            sHtml += "<li><a href='javascript:" + paginationFunction + "(" + pageCount + ")'>最后一页</a></li>";

        sHtml += "</ul></div>";

        return sHtml;
    } else {

    }


}